#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "XMysqlConnect.h"
#include "form_fwjg.h"
#include "form_recover.h"
#include "openssl/ec.h"
#include "imageshared.h"
#include "printer.h"
#include <QButtonGroup>
#include <QMainWindow>
#include <QMouseEvent>
#include <memory>
#include <functional>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

    //消息栏显示控件在staticWidget里的位置
    enum XiaoXi{
        XIAOXI=0,
        CANSHU=1,
        CUOWU=3,
        JINGAO=2,
    };

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void login(QString s,std::shared_ptr<XMysqlConnect>sql);
private slots:
    void fwjgShared();    //图像分发

    void recoverRecover();//图像恢复

    void on_pushButton_shared_clicked();//切换到图像分发界面

    void on_pushButton_recover_clicked();//切换到图像恢复界面

    void on_pushButton_steganography_clicked();//切换到图像隐藏界面

    void mousePressEvent(QMouseEvent *event) override;

    void on_pushButton_open_clicked();//打开图像

    void on_pushButton_save_clicked();//保存图像

    void on_pushButton_XiaoXiLan_clicked();//切换消息栏

    void on_listWidget_pub_customContextMenuRequested(const QPoint &pos);//右侧公共目录右键菜单

    void on_pushButton_choice_clicked();

    void on_pushButton_CanShu_clicked();

    void on_pushButton_cuowu_clicked();

    void on_pushButton_JingGao_clicked();

    void on_pushButton_choice_car_clicked();

    void on_pushButton_hite_clicked();     //隐藏信息

    void on_pushButton_extraction_clicked();//提取信息

    void on_pushButton_xiaoxi_min_clicked();//消息栏最小化

    void on_pushButton_Search_clicked();

private:
    Ui::MainWindow *ui=nullptr;
    Form_fwjg fwjg{this};         //秘密分发界面
    Form_recover recover{this};   //秘密回复界面
    imageShared m_shared{nullptr};//秘密分发类
    QString savePos{""};        //影子图像保存目录
    QString imagePos=QString(); //图片路径
    QImage carIamge{};          //载体图片
    QFileInfo fInfo{};          //照片信息
    QButtonGroup buttonGroup{this};//左侧工具栏按钮组
    QButtonGroup buttonGroupXiaoXi{this};//下侧信息栏按钮组
    std::shared_ptr<XMysqlConnect> m_sql;
    Printer* printer=nullptr;
private:
    std::function<void(std::string&)> fun;
    void readPubInfo();  //读取公共信息
    void printFwjg();    //打印访问结构即相关信息
    void savePubInfoToMysql(QString& pubInfoName, QString str_cnt);
    SaveMethod getMethod(int met);
    QString getPubInfoCount(std::shared_ptr<XMysqlConnect> &Sql);
};
#endif // MAINWINDOW_H
